// 引脚命名
#define MOTOR_DIR_1 2
#define MOTOR_PWM_1 3
#define MOTOR_DIR_2 4
#define MOTOR_PWM_2 5
#define MOTOR_DIR_3 6
#define MOTOR_PWM_3 7
#define MOTOR_DIR_4 8
#define MOTOR_PWM_4 9

void setup() {
  pinMode(MOTOR_DIR_1, OUTPUT);  //设置DIR_1为输出模式
  pinMode(MOTOR_PWM_1, OUTPUT);  //设置PWM_1为输出模式
  pinMode(MOTOR_DIR_2, OUTPUT);  //设置DIR_2为输出模式
  pinMode(MOTOR_PWM_2, OUTPUT);  //设置PWM_2为输出模式
  pinMode(MOTOR_DIR_3, OUTPUT);  //设置DIR_3为输出模式
  pinMode(MOTOR_PWM_3, OUTPUT);  //设置PWM_3为输出模式
  pinMode(MOTOR_DIR_4, OUTPUT);  //设置DIR_4为输出模式
  pinMode(MOTOR_PWM_4, OUTPUT);  //设置PWM_4为输出模式

  analogWrite(MOTOR_PWM_1, 50);   //输出PWM，占空比为 50/255
  analogWrite(MOTOR_PWM_2, 100);  //输出PWM，占空比为 100/255
  analogWrite(MOTOR_PWM_3, 150);  //输出PWM，占空比为 150/255
  analogWrite(MOTOR_PWM_4, 200);  //输出PWM，占空比为 200/255
}
void loop() {
  digitalWrite(MOTOR_DIR_1, HIGH);  //设置DIR_1为低电平
  digitalWrite(MOTOR_DIR_2, HIGH);   //设置DIR_2为低电平
  digitalWrite(MOTOR_DIR_3, HIGH);  //设置DIR_3为高电平
  digitalWrite(MOTOR_DIR_4, HIGH);   //设置DIR_4为高电平
  delay(5000);
  digitalWrite(MOTOR_DIR_1, LOW);   //设置DIR_1为低电平
  digitalWrite(MOTOR_DIR_2, LOW);  //设置DIR_2为低电平
  digitalWrite(MOTOR_DIR_3, LOW);   //设置DIR_3为高电平
  digitalWrite(MOTOR_DIR_4, LOW);  //设置DIR_4为高电平
  delay(5000);
}
